<template>
  <div>
    <div class="title">
      <el-divider direction="vertical" />
      <span>流程签名文件列表</span>
    </div>
    <el-empty v-if="files == null || files.length == 0" description="暂无签名文件" />
    <div v-else class="signFileList" :v-loading="loading">
      <div v-for="item in files" :key="item.Id" class="signFile" @click="showPdf(item)">
        <img v-if="item.ImgUri" :src="item.ImgUri | imageUri" :alt="item.FileName">
        <img v-else src="/image/pdf.png">
        <div class="title" :title="item.FileName">{{ item.FileName }}</div>
      </div>
    </div>
    <pdfFileView :file="file" :visible.sync="visible" />
  </div>
</template>

<script>
import { Gets, Accredit } from '@/flow/api/signFile'
import pdfFileView from '@/components/file/pdfFileView.vue'
export default {
  components: {
    pdfFileView
  },
  props: {
    logId: {
      type: String,
      default: null
    },
    isLoad: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      files: [],
      visible: false,
      loading: false,
      loadTxt: null,
      file: {
        FileName: null,
        FileUri: null
      }
    }
  },
  watch: {
    isLoad: {
      handler(val) {
        if (val) {
          this.reset()
        }
      },
      immediate: true
    }
  },
  mounted() {},
  methods: {
    showPdf(item) {
      this.loading = true
      this.file.FileName = item.FileName
      this.file.FileUri = item.FileUri
      this.accredit(item)
    },
    async accredit(item) {
      await Accredit(this.logId, item.Id)
      this.visible = true
      this.loading = false
    },
    async reset() {
      const res = await Gets(this.logId)
      this.files = res
    }
  }
}
</script>

<style scoped>

.signFileList {
    width: 100%;
    padding: 5px;
    max-height: 700px;
    overflow-y: auto;
}
.signFileList .signFile{
   width: 200px;
   height: 282px;
   position: relative;
   cursor: pointer;
   display: inline-flex;
   margin: 10px;
}

.signFileList .signFile img{
   width: 100%;
   height: 100%;
}
.signFileList .signFile .title{
   width: 200px;
    display: inline-block;
    height: 30px;
    line-height: 30px;
    position: absolute;
    z-index: 1;
    left: 0;
    bottom: 0;
    background-color: #414243a1;
    font-size: 14px;
    overflow: hidden;
}
.title span{
  font-size: 1.1rem;
  display: inline-block;
  padding-left: 10px;
}
.title .el-divider--vertical {
  width: 4px;
  margin: 0;
  height: 1.2em;
  background-color: #0095ff;
}
</style>
